package com.test.memoryapp;

import android.content.Context;
import android.database.Cursor;
import android.view.View;
import android.widget.CheckBox;
import android.widget.SimpleCursorAdapter;

public class VocabAdapter extends SimpleCursorAdapter {

	public VocabAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
		super(context, layout, c, from, to);
		this.setViewBinder(new VocabViewBinder());
	}
	
	public class VocabViewBinder implements ViewBinder{

		public boolean setViewValue(View view, Cursor c, int columnIndex) {
			if (view instanceof CheckBox){
				if (c.getString(c.getColumnIndex("target_flag")).equalsIgnoreCase("1"))
					((CheckBox) view).setChecked(true);
				else 
					((CheckBox) view).setChecked(false);
				return true;
			}
			return false;
		}
	}
}
